package org.snail.chat.service.chatchain.quartz;

import lombok.extern.log4j.Log4j;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.snail.chat.service.impl.ChatServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
import org.springframework.web.context.ContextLoader;
import org.springframework.web.context.WebApplicationContext;

import java.util.Map;


@Service
@Log4j
public class TestQuartzJob  implements Job {

    private ChatServiceImpl chatService;

    @Override
    public void execute(JobExecutionContext context) throws JobExecutionException {
        WebApplicationContext wac = ContextLoader.getCurrentWebApplicationContext();
        ChatServiceImpl chatService2 = (ChatServiceImpl) wac.getBean("chatServiceImpl");
        this.chatService = chatService2;
        Map map = chatService.findEmp();
        log.error("TestQuartzJob start");
        log.error("chatService:" );
        log.error("chatService:" +chatService2);
        log.error("map :"+map);
    }
}